package com.nintendo.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nintendo.mapper.CommentMapper;
import com.nintendo.pojo.Comment;
import com.nintendo.pojo.bo.CommentBO;
import com.nintendo.service.CommentService;
import com.nintendo.utils.SnowFlake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;

@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {
    @Autowired
    private CommentMapper commentMapper;
    @Autowired
    private SnowFlake snowFlake;
    @Override
    public void doComment(CommentBO commentBO, HttpServletRequest request) {
        Comment comment = BeanUtil.copyProperties(commentBO, Comment.class);
        comment.setId(String.valueOf(snowFlake.nextId()));
        comment.setCreatedTime(LocalDateTime.now());
        commentMapper.insert(comment);
    }
}
